package cn.kgcnews.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.kgcnews.pojo.NewsComment;
import cn.kgcnews.service.impl.CommentServiceImpl;

import com.alibaba.fastjson.JSON;

public class findNewsServlet extends HttpServlet {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		//PrintWriter out = response.getWriter();
			int currpage = 1;// 当前页码
			int pagesize = 50;// 一页显示个数
			//PrintWriter out = response.getWriter();
			//HttpSession session = request.getSession();
			String id=request.getParameter("newsid2");
			//String id = request.getParameter("newsid");
			System.out.println("taaaaaaaaaaaaaaaaaaaaaa:" + id);
			CommentServiceImpl csi = new CommentServiceImpl();
			List<NewsComment> list = csi.findAllComment(Integer.valueOf(id),currpage, pagesize);
			
			out.print(JSON.toJSONString(list));

		
		out.flush();
		out.close();
	}

	

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		this.doGet(request, response);
		out.flush();
		out.close();
	}

	
	public void init() throws ServletException {
		// Put your code here
	}

}
